<?php
namespace app\admin\model;
use think\Cache;
use think\Request;
use think\Db;
use think\Controller;

class BaseAdmin extends Controller
{
    public function getItemInfo($id = null,$userName = null)
    {
        if ($id) {
            $itemInfo = db('BaseAdmin')->where('uid',$id)->find();
        }
        if ($userName) {
            $itemInfo = db('BaseAdmin')->where('username',$userName)->find();
        }
        if ($id == null) {
            if (SITE_HOST) {
                $itemInfo['avatar'] =  $itemInfo['avatar'] ? $itemInfo['avatar'] : '/public/assets/common/images/avatar.jpg';
            } else {
                $itemInfo['avatar'] =  $itemInfo['avatar'] ? $itemInfo['avatar'] : '/assets/common/images/avatar.jpg';
            }
            return $itemInfo;
        }
        if ($itemInfo) {
            $itemInfo['nickname'] = $itemInfo['nickname'] ? $itemInfo['nickname'] : $itemInfo['username'];
            if (SITE_HOST) {
                $itemInfo['avatar'] =  $itemInfo['avatar'] ? $itemInfo['avatar'] : '/public/assets/common/images/avatar.jpg';
            } else {
                $itemInfo['avatar'] =  $itemInfo['avatar'] ? $itemInfo['avatar'] : '/assets/common/images/avatar.jpg';
            }
            return $itemInfo;
        } else {
            return false;
        }
    }
    
}